﻿using Future.DBUtility;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApplication1.DAO
{
    public class LoginDAO
    {
        DBHelper dbhelper = new DBHelper();

        /**
        *      数据库验证方法
        */
        public bool MDBValidateUser(string userNo, string password)
        {
            bool ret = false;
            try
            {
                //sql语句，查出userId的条数
                string MDBsql = @"select User_No,paseword from UserInfo where User_No ='" + userNo + "'and paseword = '" + password + "'";
                //取得数据
                SqlDataReader dr = dbhelper.ExecuteReader(MDBsql);
                if (dr.Read())
                {
                    userNo = (string)dr["User_No"];
                    StaticClass.User = userNo; //将用户名存储到全局变量中
                    ret = true;
                    
                }
                dr.Close();
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("数据库读取异常");
            }
            return ret;
        }
    }
}
